home *** CD-ROM | disk | FTP | other *** search
- // TRW2000 plug-in base file
- // Copyright (C) , 2000
- //
- // Author:
- // LiuTaoTao
- //
- // History :
- // 2000.4.26
- //
-
- #include <wdm.h>
- #include "...\INCLUDE\PLUGS.H"
-
- void CRTinit();
- void CRTexit();
- // prototypes
-
- extern "C" NTSTATUS
- DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath);
-
- VOID
- PLUGS_Unload(IN PDRIVER_OBJECT DriverObject);
-
-
- NTSTATUS
- DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
- {
- NTSTATUS ntStatus = STATUS_SUCCESS;
-
- DriverObject->DriverUnload = PLUGS_Unload;
-
- return ntStatus;
- }
-
- VOID
- PLUGS_Unload(IN PDRIVER_OBJECT DriverObject)
- {
- }
-
- PLUGS_API* api = 0 ;
-
- EXC EXPORT BOOL Plugs_Init ( PLUGS_API* plugsapi )
- {
- api = plugsapi ;
-
- CRTinit();
- return TRUE ;
- }
-
- EXC EXPORT BOOL Plugs_Exit ( )
- {
- CRTexit();
- return TRUE ;
- }
-
- // =======================================================
-
- typedef void (__cdecl *_PVFV)(void);
- #define NULL 0
-
- #pragma data_seg(".CRT$XCA")
- _PVFV __xc_a = NULL ;
-
-
- #pragma data_seg(".CRT$XCZ")
- _PVFV __xc_z = NULL ;
-
- #pragma data_seg()
-
- #pragma comment(linker, "/merge:.CRT=.data")
- #pragma comment(linker, "/merge:_LTEXT=.text")
-
- _PVFV buf_atexit[256]; //enough ??
- int top_atexit = 0;
-
- //extern "C" int _cdecl atexit( void* func )
- extern "C" int __cdecl atexit(void (__cdecl *func)(void))
-
- {
- buf_atexit[top_atexit++] = func;
- return 0;
- }
-
- void __cdecl _initterm (
- _PVFV * pfbegin,
- _PVFV * pfend
- )
- {
- while ( pfbegin < pfend )
- {
- if ( *pfbegin != NULL )
- (**pfbegin)();
- ++pfbegin;
- }
- }
-
- void CRTinit()
- {
- _initterm( &__xc_a, &__xc_z );
- }
-
- void CRTexit()
- {
- while( top_atexit )
- {
- top_atexit--;
- buf_atexit[top_atexit]();
- }
- }
-
-